Skip to content

feat: add prefix option for authentication routes#1322

Open
dimtrovich wants to merge 7 commits intocodeigniter4:developfrom
dimtrovich:feat/prefix-options-to-routes
Open

feat: add prefix option for authentication routes#1322
dimtrovich wants to merge 7 commits intocodeigniter4:developfrom
dimtrovich:feat/prefix-options-to-routes

Conversation

@dimtrovich
Copy link
Copy Markdown

Description

This pull request adds the ability to prefix all authentication route paths using a new prefix option in the routes() method.

  • New prefix option: Allows you to define a common prefix for all authentication routes (default /)
  • Refactoring: Replaces the hard-coded route group ‘/’ with a configurable $prefix variable

Benefits of this change

  • Increased flexibility - Allows you to group auth routes under a single prefix (e.g., auth/login, auth/register)
  • Better organization - Facilitates the organization of routes in complex applications
  • Consistency - Complements the existing namespace and except options
  • Backward compatible - The default value / preserves the existing behavior

Usage example

// All routes will be prefixed with ‘auth’
service(‘auth’)->routes($routes, [‘prefix’ => ‘auth’]);

// Generates: auth/login, auth/register, auth/logout, etc.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@michalsn
Copy link
Copy Markdown
Member

This makes sense. However, could we rename prefix to group? It would better align with the underlying method we use.

@dimtrovich
Copy link
Copy Markdown
Author

This makes sense. However, could we rename prefix to group? It would better align with the underlying method we use.

done

@michalsn
Copy link
Copy Markdown
Member

Please rebase your branch onto upstream/develop. If you don't have an upstream remote configured, add it first and then run:

git rebase upstream/develop

@datamweb datamweb added the GPG-Signing needed Pull requests that need GPG-Signing label Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

GPG-Signing needed Pull requests that need GPG-Signing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants